package com.kaifamiao.month03.day0321;

/**
 * 插入排序
 */
public class InsertSort1 {


    public static void main(String[] args) {
        int[] nums = {2, 1, 3, 4, 5, 9, 7};
        int temp, j;
        for(int i = 1; i < nums.length; i ++){
            temp = nums[i];
            for(j = i - 1; j >= 0 && nums[j] > temp; j --){
                nums[j + 1] = nums[j];
            }
            nums[j + 1] = temp;
        }
        for(int n : nums){
            System.out.print(n + "\t");
        }
    }
}

